package com.defysoft.waukids.cctv;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;

import com.defysoft.waukids.BaseFragment;
import com.defysoft.waukids.R;

public class Cctv_Main_F extends BaseFragment implements OnClickListener {
	View v;
	TextView wv, tv;
	int count = 0;
	GridView gv;
	TextView item[] = new TextView[5];

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		v = inflater.inflate(R.layout.cctv_main_f, null);

		setStartData();

		return v;
	}

	@Override
	public void setStartData() {
		super.setStartData();
		/* gv = (GridView) v.findViewById(R.id.CCTV_LIST_VIEW); */
		wv = (TextView) v.findViewById(R.id.CCTV_MAIN_VIEW_CCTV);
		tv = (TextView) v.findViewById(R.id.CCTV_MAIN_VIEW_TV);

		item[0] = (TextView) v.findViewById(R.id.CCTV_ITEM_TV_ONE);
		item[1] = (TextView) v.findViewById(R.id.CCTV_ITEM_TV_TWO);
		item[2] = (TextView) v.findViewById(R.id.CCTV_ITEM_TV_THREE);
		item[3] = (TextView) v.findViewById(R.id.CCTV_ITEM_TV_FOUR);
		item[4] = (TextView) v.findViewById(R.id.CCTV_ITEM_TV_FIVE);
		for (int i = 0; i < item.length; i++) {
			item[i].setOnClickListener(this);
		}
		wv.setOnClickListener(this);
		tv.setOnClickListener(this);
		}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {

		case R.id.CCTV_MAIN_VIEW_CCTV:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			break;

		case R.id.CCTV_MAIN_VIEW_TV:
			
			tv.setVisibility(View.GONE);
			wv.setVisibility(View.VISIBLE);
			
			break;

		case R.id.CCTV_ITEM_TV_ONE:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			tv.setText(item[0].getText().toString());
			break;

		case R.id.CCTV_ITEM_TV_TWO:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			tv.setText(item[1].getText().toString());
			break;
			
		case R.id.CCTV_ITEM_TV_THREE:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			tv.setText(item[2].getText().toString());
			break;
			
		case R.id.CCTV_ITEM_TV_FOUR:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			tv.setText(item[3].getText().toString());
			break;
			
		case R.id.CCTV_ITEM_TV_FIVE:
			wv.setVisibility(View.GONE);
			tv.setVisibility(View.VISIBLE);
			tv.setText(item[4].getText().toString());
			break;

		}
	}

	/*
	 * public class Cctv_Adapter extends ArrayAdapter<String>{
	 * 
	 * public Cctv_Adapter() {
	 * super(getActivity(),android.R.layout.simple_list_item_1); }
	 * 
	 * @Override public int getCount() { // TODO Auto-generated method stub
	 * return 5; }
	 * 
	 * @Override public View getView(int position, View convertView, ViewGroup
	 * parent) { return super.getView(position, convertView, parent); } }
	 */

}
